using System;
namespace ch.ethz.ssh2.packets
{
	
	/// <summary> PacketUserauthInfoRequest.
	/// 
	/// </summary>
	/// <author>  Christian Plattner
	/// </author>
	/// <version>  2.50, 03/15/10
	/// </version>
	public class PacketUserauthInfoRequest
	{
		virtual public bool[] Echo
		{
			get
			{
				return echo;
			}
			
		}
		virtual public System.String Instruction
		{
			get
			{
				return instruction;
			}
			
		}
		virtual public System.String LanguageTag
		{
			get
			{
				return languageTag;
			}
			
		}
		virtual public System.String Name
		{
			get
			{
				return name;
			}
			
		}
		virtual public int NumPrompts
		{
			get
			{
				return numPrompts;
			}
			
		}
		virtual public System.String[] Prompt
		{
			get
			{
				return prompt;
			}
			
		}
		internal byte[] payload;
		
		internal System.String name;
		internal System.String instruction;
		internal System.String languageTag;
		internal int numPrompts;
		
		internal System.String[] prompt;
		internal bool[] echo;
		
		public PacketUserauthInfoRequest(byte[] payload, int off, int len)
		{
			this.payload = new byte[len];
			Array.Copy(payload, off, this.payload, 0, len);
			
			TypesReader tr = new TypesReader(payload, off, len);
			
			int packet_type = tr.readByte();
			
			if (packet_type != Packets.SSH_MSG_USERAUTH_INFO_REQUEST)
				throw new System.IO.IOException("This is not a SSH_MSG_USERAUTH_INFO_REQUEST! (" + packet_type + ")");
			
			name = tr.readString();
			instruction = tr.readString();
			languageTag = tr.readString();
			
			numPrompts = tr.readUINT32();
			
			prompt = new System.String[numPrompts];
			echo = new bool[numPrompts];
			
			for (int i = 0; i < numPrompts; i++)
			{
				prompt[i] = tr.readString();
				echo[i] = tr.readBoolean();
			}
			
			if (tr.remain() != 0)
				throw new System.IO.IOException("Padding in SSH_MSG_USERAUTH_INFO_REQUEST packet!");
		}
	}
}